<?php
/**
 * Created by PhpStorm.
 * User: yadongw
 * Date: 15-5-26
 * Time: 下午4:42
 */
use UcxApiSdk\Client;
include 'common.php';

$client = new Client();
$client->setAccessToken($_COOKIE['ucx_access_token']);
$documentResource = $client->getDocument();
$documents = $documentResource->findAll();

?>

<html>
<head>
	<link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
	<script type="text/javascript" src="../static/jquery.min.js"></script>
	<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container-fluid">


<div class="row">
	<a class="btn btn-default" style="margin: 10px;" href="upload.php">Upload Document</a>
</div>
</div>
<table class="table table-striped table-hover form-table odTable" style="margin-top: 20px;table-layout: fixed;min-width:1000px;"><thead>
	<tr><th style="width:40px;">#</th><th>Name</th><th style="width:150px;"></th></tr>
	</thead>
	<tbody>
	<?php foreach($documents as $k => $document): ?>
	<tr>
		<td><?= ($k + 1) ?></td>
		<td style="white-space:nowrap;width:100%;text-overflow: ellipsis; overflow:hidden;"><a href="preview.php?did=<?= $document['doc_id'] ?>"><?= $document['name'] ?></a></td>
		<td>
			<div class="btn-group">
				<button id="w1" class="btn-default btn-xs btn dropdown-toggle" href="#" data-toggle="dropdown">Actions <span class="caret"></span></button>
				<ul id="w2" class="dropdown-menu" style="min-width:120px;">
					<li><a href="web-link.php?did=<?= $document['doc_id'] ?>" tabindex="-1"><span class="glyphicon glyphicon-share" title="Web Link"></span> Web Link</a></li>
					<li><a href="preview.php?did=<?= $document['doc_id'] ?>" tabindex="-1"><span class="glyphicon glyphicon-eye-open" title="View"></span> View</a></li>
					<li><a href="detail.php?did=<?= $document['doc_id'] ?>" tabindex="-1"><span class="glyphicon glyphicon-pencil" title="Detail"></span> Detail</a></li>
					<li><a href="document.php?action=download&did=<?= $document['doc_id'] ?>" tabindex="-1"><span class="glyphicon glyphicon-download-alt" title="Download"></span> Download</a></li>
					<li><a href="document.php?action=delete&did=<?= $document['doc_id'] ?>" tabindex="-1"><span class="glyphicon glyphicon-remove" title="Delete"></span> Delete</a></li></ul>
			</div>
		</td>
	</tr>
	<?php endforeach; ?>
	</tbody>
</table>
</body>
</html>